import argparse
import sys

def parse_args():
    parser = argparse.ArgumentParser("")
    parser.add_argument("--tsv", type=str,required=True)
    return parser.parse_args()

def extract(args):
    pos=0
    pos_cg=0
    neg=0
    neg_cg=0
    with open(args.tsv,'r') as rb:
        for line in rb:
            words=line.strip().split('\t')
            seq=words[3]
            pred_poss=words[5].split(',')
            biss=words[15].split(',')
            for i in range(len(pred_poss)):
                pred_pos=int(pred_poss[i])
                if pred_pos==len(seq)-1:
                    pred_dorado=float(words[6].split(',')[i])
                    pred_deepsignal=float(words[7].split(',')[i])
                    print('------------')
                    print('dorado: {}'.format(pred_dorado))
                    print('deepsignal: {}'.format(pred_deepsignal))
                    print('------------')
                bis=float(biss[i])
                flag=0
                if bis==100.0:
                    pos+=1
                    flag=1
                elif bis==0.0:
                    neg+=1
                else:
                    continue                
                if seq[pred_pos:pred_pos+2]=='CG':
                    if flag==1:
                        pos_cg+=1
                    else:
                        neg_cg+=1
    print('pos: {}'.format(pos))
    print('CG pos: {}'.format(pos_cg))
    print('neg: {}'.format(neg))
    print('CG neg: {}'.format(neg_cg))


                
            
def main():
    args=parse_args()
    extract(args)

if __name__ == '__main__':
    sys.exit(main())